package com.tesis_2.Utils;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

import com.example.tesis_2.R;
import com.tesis_2.MO.MOComentario;
import com.tesis_2.MO.MORestaurant;

public class UTComentariosArrayAdapter extends  ArrayAdapter<MOComentario> {
	
	private final Context context;
	private final ArrayList<MOComentario> values;
	
	public UTComentariosArrayAdapter(Context context, ArrayList<MOComentario> values ) {
		super(context, R.layout.activity_comentarios, values);
		this.context = context;
		this.values = values;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View rowView = inflater.inflate(R.layout.activity_comentarios, parent, false);
		
		((TextView) rowView.findViewById(R.id.txvUsuario_comentarios)).setText( ((MOComentario) getItem(position)).getUsrname());
		((TextView) rowView.findViewById(R.id.txvComentario_comentarios)).setText( ((MOComentario) getItem(position)).getCmt());
		((TextView) rowView.findViewById(R.id.txvFecha_comentarios)).setText( ((MOComentario) getItem(position)).getCreated_at().toString());
		((RatingBar) rowView.findViewById(R.id.rbRate_comentarios)).setRating(( ((MOComentario) getItem(position)).getRate()));
		return rowView;
	}
}
